<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../../system/admin/top.jsp"%>
</head>
<body>

	<div class="container-fluid" id="main-container">


		<div id="page-content" class="clearfix">

			<div class="row-fluid">

				<div class="row-fluid">

					<!-- 检索  -->
					<form action="applygetmaterials/list.do" method="post" name="Form"
						id="Form">
						<table>
							<tr>
								<td><span class="input-icon"> <input
										autocomplete="off" id="keyword" type="text" name="keyword"
										value="" placeholder="这里输入关键词" /> <i id="nav-search-icon"
										class="icon-search"></i>
								</span></td>
								<td><input class="form_datetime" name="lastLoginStart"
									id="lastLoginStart" value="${pd.lastLoginStart}" type="text"
									readonly="readonly" style="width: 150px;" placeholder="开始日期" /></td>
								<td><input class="form_datetime" name="lastLoginEnd"
									id="lastLoginEnd" value="${pd.lastLoginEnd}" type="text"
									readonly="readonly" style="width: 150px;" placeholder="结束日期" /></td>
								<td style="vertical-align: top;"><select
									class="chzn-select" name="check_state" id="check_state"
									data-placeholder="请选择审核状态"
									style="vertical-align: top; width: 120px;">
										<option value="-1">审批状态</option>
										<option value="0">待审批</option>
										<option value="1">通过</option>
										<option value="2">驳回</option>
								</select></td>
								<td style="vertical-align: top;"><select
									class="chzn-select" name="pay_state" id="pay_state"
									data-placeholder="请选择付款状态"
									style="vertical-align: top; width: 120px;">
										<option value="-1">付款状态</option>
										<option value="0">等待审批</option>
										<option value="1">待付款</option>
										<option value="2">已提交支付凭证</option>
										<option value="2">已付款</option>
								</select></td>
								<td style="vertical-align: top;"><select
									class="chzn-select" name="get_state" id="get_state"
									data-placeholder="请选择领取状态"
									style="vertical-align: top; width: 120px;">
										<option value="-1">领取状态</option>
										<option value="0">等待通知</option>
										<option value="1">待领取</option>
										<option value="2">已领取</option>
								</select></td>
								<td style="vertical-align: top;"><button
										class="btn btn-mini btn-light" onclick="search();" title="检索">
										<i id="nav-search-icon" class="icon-search"></i>
									</button></td>
							</tr>
						</table>
						<!-- 检索  -->


						<table id="table_report"
							class="table table-striped table-bordered table-hover">

							<thead>
								<tr>
									<th class="center">序号</th>
									<th class="center">项目名称</th>
									<th class="center">申请人</th>
									<th class="center">申请人部门</th>
									<th class="center">申请时间</th>
									<th class="center">申请物品</th>
									<th class="center">需付费用</th>
									<th class="center">申请状态</th>
									<th class="center">付费状态</th>
									<th class="center">领取状态</th>
									<th class="center">操作</th>
								</tr>
							</thead>

							<tbody>

								<!-- 开始循环 -->
								<c:choose>
									<c:when test="${not empty varList}">
										<c:if test="${QX.cha == 1 }">
											<c:forEach items="${varList}" var="var" varStatus="vs">
												<tr>
													<td class='center' style="width: 30px;">${vs.index+1}</td>
													<td><c:if test="${var.apply_type==0}">内部申请</c:if> <c:if
															test="${var.apply_type==1}">${var.project_id}</c:if></td>
													<td>${var.USERNAME}</td>
													<td>${var.department_name}</td>
													<td>${var.create_time}</td>
													<td><a
														href="javaScript:toDetail('${var.apply_get_materials_id}')">
															<c:if test="${fn:length(var.applyGoods)>=20}">${fn:substring(var.applyGoods, 0,20)}...</c:if>
															<c:if test="${fn:length(var.applyGoods)<20}">${var.applyGoods}</c:if>
													</a></td>
													<td>${var.account}</td>
													<td><c:if test="${var.check_state==0}">
															待审核
														</c:if> <c:if test="${var.check_state==1}">
															同意
														</c:if> <c:if test="${var.check_state==2}">
															驳回
														</c:if></td>
													<td><c:if test="${var.pay_state==0}">
															等待审批
														</c:if> <c:if test="${var.pay_state==1}">
															待支付
														</c:if> <c:if test="${var.pay_state==2}">
															已提交支付凭证
														</c:if> <c:if test="${var.pay_state==3}">
															已付款
														</c:if></td>
													<td><c:if test="${var.get_state==0}">
															等待通知
														</c:if> <c:if test="${var.get_state==1}">
															待领取
														</c:if> <c:if test="${var.get_state==2}">
															已领取
														</c:if></td>
													<td style="width: 30px;" class="center">
														<div class='hidden-phone visible-desktop btn-group'>

															<c:if test="${QX.edit != 1 && QX.del != 1 }">
																<span
																	class="label label-large label-grey arrowed-in-right arrowed-in"><i
																	class="icon-lock" title="无权限"></i></span>
															</c:if>
															<div class="inline position-relative">
																<button class="btn btn-mini btn-info"
																	data-toggle="dropdown">
																	<i class="icon-cog icon-only"></i>
																</button>
																<ul
																	class="dropdown-menu dropdown-icon-only dropdown-light pull-right dropdown-caret dropdown-close">
																	<c:if test="${QX.edit == 1 && pd.userId==var.user_id}">
																		<c:if test="${var.check_state==0}">
																			<li><a style="cursor: pointer;" title="编辑"
																				onclick="edit('${var.apply_get_materials_id}');"
																				class="tooltip-success" data-rel="tooltip" title=""
																				data-placement="left"><span class="green">编辑</span></a></li>
																		</c:if>
																		<c:if test="${var.pay_state==1}">
																			<li><a style="cursor: pointer;" title="提交支付凭证"
																				onclick="submitDocument('${var.apply_get_materials_id}');"
																				class="tooltip-success" data-rel="tooltip" title=""
																				data-placement="left"><span class="green">提交支付凭证</span></a></li>
																		</c:if>
																		<c:if test="${var.pay_state==3 && var.get_state==1 && var.inform_get_type==0}">
																			<!-- 待领取 -->
																			<li><a style="cursor: pointer;" title="填写领取人信息"
																				onclick="goFillPerson('${var.apply_get_materials_id}');"
																				class="tooltip-success" data-rel="tooltip" title=""
																				data-placement="left"><span class="green">填写领取人信息</span></a></li>
																		</c:if>
																	</c:if>
																	<c:if test="${var.pay_state==3 && var.get_state==0}">
																		<!-- 已经缴费 -->
																		<li><a style="cursor: pointer;" title="发布领取通知"
																			onclick="goIssueInfrom('${var.apply_get_materials_id}');"
																			class="tooltip-success" data-rel="tooltip" title=""
																			data-placement="left"><span class="green">通知领取</span></a></li>
																	</c:if>


																</ul>
															</div>
														</div>
													</td>
												</tr>

											</c:forEach>
										</c:if>
										<c:if test="${QX.cha == 0 }">
											<tr>
												<td colspan="100" class="center">您无权查看</td>
											</tr>
										</c:if>
									</c:when>
									<c:otherwise>
										<tr class="main_info">
											<td colspan="100" class="center">没有相关数据</td>
										</tr>
									</c:otherwise>
								</c:choose>
							</tbody>
						</table>

						<div class="page-header position-relative">
							<table style="width: 100%;">
								<tr>
									<td style="vertical-align: top;"><c:if
											test="${QX.add == 1 }">
											<a class="btn btn-small btn-success" onclick="add();">申请领取物资</a>
										</c:if></td>
									<td style="vertical-align: top;"><div class="pagination"
											style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}</div></td>
								</tr>
							</table>
						</div>
					</form>
				</div>




				<!-- PAGE CONTENT ENDS HERE -->
			</div>
			<!--/row-->

		</div>
		<!--/#page-content-->
	</div>
	<!--/.fluid-container#main-container-->

	<!-- 返回顶部  -->
	<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse"> <i
		class="icon-double-angle-up icon-only"></i>
	</a>

	<!-- 引入 -->
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/ace-elements.min.js"></script>
	<script src="static/js/ace.min.js"></script>

	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript" src="static/js/bootstrap-datetimepicker.js"></script>
	<!-- 日期框 -->
	<script type="text/javascript" src="static/js/bootbox.min.js"></script>
	<!-- 确认窗口 -->
	<!-- 引入 -->
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>
	<!--提示框-->
	<script type="text/javascript">
		
		$(top.hangge());
		
		//检索
		function search(){
			top.jzts();
			$("#Form").submit();
		}
		
		//新增
		function add(){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '<%=basePath%>applygetmaterials/goAdd.do';
			 diag.Width = 500;
			 diag.Height = 500;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//去详情
		function toDetail(Id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="详情";
			 diag.URL = '<%=basePath%>applygetmaterials/goDetail.do?apply_get_materials_id='+Id;
			 diag.Width = 500;
			 diag.Height = 500;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		
		//删除
		function del(Id){
			bootbox.confirm("确定要删除吗?", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>applygetmaterials/delete.do?APPLYGETMATERIALS_ID="+Id+"&tm="+new Date().getTime();
					$.get(url,function(data){
						nextPage(${page.currentPage});
					});
				}
			});
		}
		
		//修改
		function edit(Id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL = '<%=basePath%>applygetmaterials/goEdit.do?apply_get_materials_id='+Id;
			 diag.Width = 450;
			 diag.Height = 355;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		//提交支付凭证
		function submitDocument(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="提交支付凭证";
			 diag.URL = '<%=basePath%>applypaymentdocument/goAdd.do?apply_get_materials_id='+id;
			 diag.Width = 500;
			 diag.Height = 500;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		//发布领取通知
		function goIssueInfrom(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="发送领取通知";
			 diag.URL = '<%=basePath%>applygetmaterials/goIssueInfrom.do?apply_get_materials_id='+id;
			 diag.Width = 500;
			 diag.Height = 500;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//填写领取人信息
		function goFillPerson(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="填写领取人信息";
			 diag.URL = '<%=basePath%>applygetmaterials/goFillPerson.do?apply_get_materials_id='+id;
			 diag.Width = 500;
			 diag.Height = 500;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		
		
		</script>

	<script type="text/javascript">
		
		$(function() {
			
			//下拉框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$(".form_datetime").datetimepicker( {
                autoclose:true,
                format: "yyyy-mm-dd hh:ii",
                language: 'cn',
                clearBtn:true,
                todayHighlight: true
            });
			
			//复选框
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});
			
		});
		
		
		//批量操作
		function makeAll(msg){
			bootbox.confirm(msg, function(result) {
				if(result) {
					var str = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++)
					{
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  }
					}
					if(str==''){
						bootbox.dialog("您没有选择任何内容!", 
							[
							  {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback": function() {
									//Example.show("great success");
									}
								}
							 ]
						);
						
						$("#zcheckbox").tips({
							side:3,
				            msg:'点这里全选',
				            bg:'#AE81FF',
				            time:8
				        });
						
						return;
					}else{
						if(msg == '确定删除吗?'){
							top.jzts();
							$.ajax({
								type: "POST",
								url: '<%=basePath%>applygetmaterials/deleteAll.do?tm='+new Date().getTime(),
						    	data: {DATA_IDS:str},
								dataType:'json',
								//beforeSend: validateData,
								cache: false,
								success: function(data){
									 $.each(data.list, function(i, list){
											nextPage(${page.currentPage});
									 });
								}
							});
						}
					}
				}
			});
		}
		
		//导出excel
		function toExcel(){
			window.location.href='<%=basePath%>applygetmaterials/excel.do';
		}
		</script>

</body>
</html>

